suppressMessages(library(tidyverse))

library(RColorBrewer)
qual_col_pals <- brewer.pal.info[brewer.pal.info$category == "qual", ]
col_vector <- unlist(map2(qual_col_pals$maxcolors, rownames(qual_col_pals), ~ brewer.pal(.x, .y))) %>%
  unique() %>%
  .[-4]


if (F) {
  library(rcartocolor)
  map2(
    rep(12, length(cartocolors %>% filter(Type == "qualitative") %>% pull(Name))),
    cartocolors %>% filter(Type == "qualitative") %>% pull(Name), ~ carto_pal(.x, .y)
  ) -> plates

  names(plates) <- cartocolors %>%
    filter(Type == "qualitative") %>%
    pull(Name)

  write_rds(plates, file = "/Pub/Users/wangyk/Project_wangyk/Codelib_YK/some_scr/DataVisualization/plates.RDS")
}

# plates <- readRDS("/Pub/Users/wangyk/Project_wangyk/Codelib_YK/some_scr/DataVisualization/plates.RDS")

plates2 <- list(
  NatMed =c(
    "#6DCCDD", "#EDCAE0", "#F494BE", "#F9B26C", "#A6ADCC", "#C4DA5D",
    "#9ec5ff", "#aadca2", "#e0e07c", "#fa9c77","#fdd976","#215ea8","#f768a0","#41ab5d",
    "#d55f4d","#d7859d","#689e45", "#5a8ba8","#92c1b6","#dfc27c","#80b0d2","#fa8071","#ce5344"
  ),
  div1 = c("#6DCCFD",'white', "#FD9AA0"),
  div2 = c("#274369",'white', "#680020"),
  div3 = c("#702b0e",'white', "#245b31"),
  div4 = c('#052f60',"white","#6d021f"),
  div5 = c('#394fa8',"black","#e6de30"),
  div6 = c("#0000FF", "#8888FF", "#AAAAFF", "#FFFFFF", "#FF8888", "#FF5555", "#FF0000"),
  seq1 = c("#ffcccc", "#66cccc", "#9999cc", "#ff99cc", "#ff9966", "#cccc66"),
  long1 = c(
    "#6DCCDD", "#9ACBDE", "#C8CADF", "#EDC6DD", "#F092B1", "#F27FA5", "#F47892",
    "#F6A395", "#F8AD77", "#E7B080", "#C9AFA2", "#ABADC5", "#AEB9AC", "#B9C984", "#C4DA5D"
  ),
  short1 = c("#99cc99", "#99ccff", "#cc6699", "#ffcc99")
)

plates3 <- list(
  zhang_t_cell = c(
    "#48b2e9", "#f3c300", "#f38400", "#a1caf1", "#be0032", "#c2b280",
    "#848482", "#008856", "#e68fac", "#0067a5", "#f99379",
    "#604e97", "#f6a600", "#b3446c",
    "#dcd300", "#882d17", "#8db600", "#e25822", "#2b3d26"
  ),
  macarons = c(
    "#E6A8D7", "#00A896", "#A7C5EB", "#FF6B6B",
    "#63E6BE", "#CAB8FF", "#FFD166", "#FFAAA5", "#A0E7E5", "#E5989B",
    "#F4DB77", "#6A0572", "#FF85A2", "#00CCCD",
    "#c4a1f9", "#FF2E63", "#2400A6", "#FFD3B6", "#774AAB", "#219EBC",
    c(
      "#f3a0a1", "#6CB4EE", "#FFA07A", "#a0d7e6",
      "#FF69B4", "#A9A9A9", "#FFD700", "#87CEEB", "#FF7F50",
      "#C0C0C0", "#98FB98", "#DAA520", "#40E0D0",
      "#FFE4C4", "#DDA0DD", "#B0E0E6", "#FF6347", "#7B68EE"
    )
  ),
  zzm8colors = c(
    "#d4de9c", "#94c58f", "#86c7b4", "#9cd2ed", "#a992c0",
    "#ea9994", "#f2c396", "#bb82b1"
  ),
  zzm60colors = c(
    "#4b6aa8", "#3ca0cf", "#c376a7", "#ad98c3", "#cea5c7",
    "#53738c", "#a5a9b0", "#a78982", "#696a6c", "#92699e",
    "#d69971", "#df5734", "#6c408e", "#ac6894", "#d4c2db",
    "#537eb7", "#83ab8e", "#ece399", "#405993", "#cc7f73",
    "#b95055", "#d5bb72", "#bc9a7f", "#e0cfda", "#d8a0c0",
    "#e6b884", "#b05545", "#d69a55", "#64a776", "#cbdaa9",
    "#efd2c9", "#da6f6d", "#ebb1a4", "#a44e89", "#a9c2cb",
    "#b85292", "#6d6fa0", "#8d689d", "#c8c7e1", "#d25774",
    "#c49abc", "#927c9a", "#3674a2", "#9f8d89", "#72567a",
    "#63a3b8", "#c4daec", "#61bada", "#b7deea", "#e29eaf",
    "#4490c4", "#e6e2a3", "#de8b36", "#c4612f", "#9a70a8",
    "#76a2be", "#408444", "#c6adb0", "#9d3b62", "#2d3462"
  )
)

# jsonlite::write_json(plates3, "/Pub/Users/wangyk/Project_wangyk/Codelib_YK/some_scr/DataVisualization/palettes3.json")
# jsonlite::write_json(plates2, "/Pub/Users/wangyk/Project_wangyk/Codelib_YK/some_scr/DataVisualization/palettes2.json")
